package web.service.rest;

import cn.edu.hit.kg.entity.BaseNode;

import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.*;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import java.util.Collections;
import java.util.Map;

@Path("/kg")
public class KGService {
    final static Map<String, Boolean> isRunMap = Collections.singletonMap("isRun", true);

    @Context
    HttpServletRequest request;

    @GET
    @Produces(MediaType.APPLICATION_JSON)
    public Map<String, Boolean> isRun() {
        return isRunMap;
    }


    @GET
    @Path("/{id}")
    @Produces(MediaType.APPLICATION_JSON)
    public Map getNode(@PathParam("id") long id) {
        BaseNode node = BaseNode.nodeCache.get(id);
        return node.toJson();
    }


    private Map<String, Object> singleValue(Object value) {
        return Collections.singletonMap("value", value);
    }

    public void setRequest(HttpServletRequest request) {
        this.request = request;
    }
}
